#ifndef __LIOCOM_H__
#define __LIOCOM_H__

#include "liotool.h"

#pragma comment(lib, "ws2_32.lib" )
#pragma warning(disable:4996)

#ifndef NO_ERROR
#define NO_ERROR 0
#endif

#define IP_BROADCAST "255.255.255.255"
#define IP_LOCALHOST "127.0.0.1"
#define IP_NOTSPECIF "0.0.0.0"

#define SOCKET_REV 2
#define SOCKET_VER 2

namespace Lio {

class Socket
{
protected:
	int startup();
	int terminate();
	SOCKET sockid;
	WSADATA wsaData;
	char strip[16];
	SOCKADDR_IN servaddr,localaddr;
	ULONG ip;
	WORD localport, remoteport;
public:
	int error;
	Socket(BYTE revision = 2, BYTE version = 2);
	~Socket();
	BOOL connect(const char * remoteIP, WORD remotePort, WORD localPort = 0);
	void disconnect();
	BOOL receive(void *buffer, int n);
	BOOL send(const void *buffer, int n);
	const WSADATA *info() const {return &wsaData;}
};

}; // namespace Lio

#endif // __LIOCOM_H__